import { Component, OnInit } from '@angular/core';
import {BaseLoginComponent} from '../base-login/base-login.component';
import {BaseRegisterComponent} from '../base-register/base-register.component';
import {Router} from "@angular/router";

var $=require('jquery');
var img=require('modules/img');
var base=require('modules/base');
@Component({
  selector: 'app-base-header',
  templateUrl: './base-header.component.html',
  styleUrls: ['./base-header.component.less']
})
export class BaseHeaderComponent implements OnInit {
	username =''; //登录时输入的用户名
	password = ''; //登录时输入的密码
  href = location.href;
  boo = this.href.indexOf('index.html') > -1 || this.href.indexOf('html') === -1;
  booo = /info\.html/.test(this.href);
  img_path= this.boo ? 'style/img/' : this.booo ? '../style/img/' : '../src/style/img/';
  topac= 0;
	useRouter=1;
  link=this.boo ? './view' : '.';
  url=this.boo ? '.' : '..';
  vip= img.vip;
  vip1= img.vip1;
  guanzhu= img.guanzhu;
  guanzhu1= img.guanzhu1;
  biaodan= img.biaodan;
  biaodan1= img.biaodan1;
  xgmm= img.xgmm;
  xgmm1= img.xgmm1;
  tuichu= img.tuichu;
  tuichu1= img.tuichu1;
  // loginbox=true;//登录的button按钮的判断能否点击的参数
  ismycountshow= false; //我的账户的显示与否的参数
  isLoginshow= true; //登录和注册的框显示与否
  isChecked= false;
  ismycountlistshow= false; //我的账户列表显示与隐藏
  regiterpara= 0; //判断能否点击注册的参数
  loginp={
  	isLoginShow:!1,
  	username:this.username,
  	password:this.password
  };
	registerp={
		isRegisterShow:!1
	};
	toIndex() {
      //点击左上角的logo
//    this.$router.push({ path: '/index' });
 };
  toMyAccount(i){//点击我的账户
    this.topac = 5;
//  this.$router.push({path:'/account'})
  };
  loginorregister(e,index) {
  	if(index==0){
  		this.loginp.isLoginShow=!0;
  	}else if(index==1){
  		this.registerp.isRegisterShow=!0;
  	}
//	console.log(e.target.nodeName);
//  if (e.target.nodeName === 'A') {
//        // 登录
//    var tar = e.target,
//        index = $(tar).index();
//    $(".cover-box").toggle().find('.login-action').eq(index).show();
//    if (!$(tar).hasClass('active')) $(tar).addClass('active').siblings('a').removeClass('active');
//  }
  };
  mycount(e) {
      this.ismycountlistshow = true;
  };
  vanish(e){
      this.ismycountlistshow = false;
  };
  logout() {
      sessionStorage.removeItem("sid");
      sessionStorage.removeItem("username");
      this.ismycountshow = false;
      this.isLoginshow = true;
  };
  islogined() {
    //判断sid是否存在
    if (window.sessionStorage && window.sessionStorage.getItem('sid')) {
        this.ismycountshow = true;
        this.isLoginshow = false;
        this.username = window.sessionStorage.getItem('username');
    }
  };
  accountlist(e) {
      $(e).find("a").css({ 'color': "#11bdc5" });
      $(".account-list>a").css({ "color": "#555" });
      $(".account-list").find(".firstPic").removeClass("display-none");
      $(".account-list").find(".secondPic").addClass("display-none");
      $(e.target).find(".firstPic").addClass("display-none");
      $(e.target).find(".secondPic").removeClass("display-none");
  };
  subHref(href) {
      var str = href.substring(href.indexOf('?') + 1, href.length);
      return str.split('&');
  };
  constructor(private router:Router) { 
  	
  	
		window['header']=this;
  	
  }
	tapRouter(e, r){
	    switch (r) {
	      case '0':
	          //点击院校推荐
//	          this.router.
	//        this.$router.push({ path: '/recommond' });
	          this.topac = 1;
	          break;
	      case 1:
	          //点击信息库
	//        this.$router.push({ path: '/infolib' });
	          this.topac = 2;
	          break;
	      case 2:
	          //点击app下载
	//        this.$router.push({ path: '/load' });
	          this.topac = 3;
	          break;
	      case 3:
	          //点击成为vip
	//        this.$router.push({ path: '/vip' });
	          this.topac = 4;
	          break;
	    }
	  }
  ngOnInit() {
  }
	
}
